//
//  LHMapView.m
//  Knight_Tour
//
//  Created by Bruce_Lin on 15/5/13.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHSearchMapView.h"

@implementation LHSearchMapView

- (void)dealloc
{
    [_KeyWordTextField release];
    [_cityNameTextField release];
    [_corrcetAddress release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        [self creatSearchView];
    }
    return self;
}

- (void)creatSearchView
{
    UIImageView *image = [[UIImageView alloc] initWithFrame:self.bounds];
    image.image = [UIImage imageNamed:@"globe1"];
    image.userInteractionEnabled = YES;
    [self addSubview:image];
    [image release];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(returnKeyBoard)];
    [image addGestureRecognizer:tap];
    [tap release];
    
    UILabel *corrcetAddressLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, LHheight / 13 - 20, LHWidth, 30)];
    corrcetAddressLabel.textColor = [UIColor whiteColor];
    corrcetAddressLabel.text = @"你现在在这 ⬇️";
    corrcetAddressLabel.textAlignment = NSTextAlignmentCenter;
    [corrcetAddressLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:20]];
    [image addSubview:corrcetAddressLabel];
    [corrcetAddressLabel release];
    
    self.corrcetAddress = [[UILabel alloc]initWithFrame:CGRectMake(0, LHheight / 12.7, LHWidth, 30)];
    _corrcetAddress.textColor = [UIColor whiteColor];
    [_corrcetAddress setNumberOfLines:2];
    _corrcetAddress.textAlignment = NSTextAlignmentCenter;
    [_corrcetAddress setFont:[UIFont fontWithName:@"Helvetica-Bold" size:17]];
    [image addSubview:_corrcetAddress];
    [_corrcetAddress release];

    
    UILabel *cityName = [[UILabel alloc]initWithFrame:CGRectMake(LHWidth / 2 - 200, LHheight / 5.2, 200, 30)];
    cityName.text = @"想去哪儿(城市) ->";
    cityName.textColor = [UIColor whiteColor];
    cityName.textAlignment = NSTextAlignmentRight;
    [cityName setFont:[UIFont fontWithName:@"Helvetica-Bold" size:20]];
    [image addSubview:cityName];
    [cityName release];
    
    self.cityNameTextField= [[UITextField alloc]initWithFrame:CGRectMake(LHWidth / 2, LHheight / 5.2, 80, 30)];
    _cityNameTextField.backgroundColor = [UIColor whiteColor];
    _cityNameTextField.textAlignment = NSTextAlignmentCenter;
    _cityNameTextField.layer.cornerRadius = 10;
    _cityNameTextField.layer.borderWidth = 1.0f;
    _cityNameTextField.delegate = self;
    [image addSubview:_cityNameTextField];
    [_cityNameTextField release];
    
    
    UILabel *key = [[UILabel alloc]initWithFrame:CGRectMake(LHWidth / 2 - 150, LHheight / 3.3, 150, 30)];
    key.text = @"关键字 ->";
    key.textColor = [UIColor whiteColor];
    key.textAlignment = NSTextAlignmentRight;
    [key setFont:[UIFont fontWithName:@"Helvetica-Bold" size:20]];
    [image addSubview:key];
    [key release];
    
    self.KeyWordTextField = [[UITextField alloc]initWithFrame:CGRectMake(LHWidth / 2, LHheight / 3.3, 80, 30)];
    _KeyWordTextField.textAlignment = NSTextAlignmentCenter;
    _KeyWordTextField.backgroundColor = [UIColor whiteColor];
    _KeyWordTextField.layer.borderWidth = 1.0f;
    _KeyWordTextField.layer.cornerRadius = 10;
    _KeyWordTextField.delegate = self;
    [image addSubview:_KeyWordTextField];
    [_KeyWordTextField release];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

- (void)returnKeyBoard
{
    [_cityNameTextField resignFirstResponder];
    [_KeyWordTextField resignFirstResponder];
}

 

@end
